'use strict';

var mysql = require('mysql');
var connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'equipment'
});

connection.connect();

//查询
//执行数据库操作并执行回调，有err则抛出异常，控制台输出结果

connection.query('DELETE FROM e_instrument WHERE id=2', function (error , fields) {

    if (error) {
        console.log('出错了！');
    }
    console.log('删除成功！:');
   
});
//查询结果并输出
connection.query('select * from e_instrument', function (error, results, fields){
    console.log('删除后的数据为：',results);
   });

//关闭连接
connection.end();